package 
{
	import flash.display.Sprite;
	import flash.events.Event;	
	import flash.geom.Matrix;
	
	/**
	 * 
	 * @author Lorenzo Nuvoletta
	 */
	public class IsoGen extends Sprite 
	{		
		private var hypotenuse		:Number;
		private var angleT			:Number;
		private var angleTDegrees	:Number;
		private var A				:Number;
		private var B				:Number;
		
		public function IsoGen():void 
		{			
			//Dimension of the square
			var originalDimension:uint = 32;
			
			var s:Sprite = new Sprite();
			s.graphics.beginFill(0xCC0000);
			s.graphics.drawRect(0, 0, originalDimension, originalDimension);
			s.graphics.endFill();		
			addChild(s);			
			
			//Rotate 45 degrees and scaleY half.
			var matrix:Matrix = new Matrix();
			matrix.rotate(Math.PI / 4);
			matrix.scale(1, .5);
			s.transform.matrix = matrix;
			
			//My triangle: 
			A = s.width / 2;
			B = s.height / 2
			
			// Find the angle opposite to side B.
			angleT = Math.atan(B / A); // in radians
			angleTDegrees = angleT * (180 / Math.PI);
			
			hypotenuse = B / Math.sin(angleT);
			
			trace("AngleT:",angleT, "AngleTDegrees:",angleTDegrees, "A:",A, "B:",B, "Hypotenuse:",hypotenuse);			
		}
		
	}
	
}